<template>
  <div>
    <ul>
      <li v-for="item in arr" :key="item.id">
        {{ item.num }} <button @click="del(item.id)">删除</button>
      </li>
    </ul>
    <button @click="make">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [],
    };
  },
  methods: {
    make() {
      const obj = {
        id: +new Date(),
        num: Math.floor(Math.random() * 100),
      };
      this.arr.push(obj);
    },
    del(id) {
      this.arr = this.arr.filter((item) => item.id !== id);
    },
  },
};
</script>

<style scoped></style>
